package Stream流;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.function.Function;
import java.util.stream.Stream;

public class Stream_api {
    public static void main(String[] args) {
        List<String> a=new ArrayList<>();
        Collections.addAll(a,"张哲峰","张叔叔","张鱼","你爹");
        //1.筛选
        a.stream().filter(s->s=="你爹").forEach(s-> System.out.println(s));
        //2.limit和skip
        //limit是选择从头开始的俩个元素skip是跳过元素
        //3.map加工
//        a.stream().map(new Function<String, String>() {
//            @Override
//            public String apply(String s) {
//                return "煞笔"+s;
//            }
//        });
        a.stream().map((String s)-> "煞笔"+s).forEach(s -> System.out.println(s));
        //合并流
        Stream<String> a1=a.stream();
        Stream<String> a2=a.stream();
        //如果数据不一样就用他们的父类接
        Stream<String> a3=Stream.concat(a1,a2);
        a3.forEach(s-> System.out.println(s));
    }
}
